package com.wish.g04.file.controller;

import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Z-7
 * @Date 2022/5/25
 */
@RestController
@RequestMapping("qiniu")
public class QiNiuController {

    /**
     * 七牛云秘钥
     */
    @Value("${file.accessKey}")
    private String accessKey;

    /**
     * 七牛云秘钥
     */
    @Value("${file.secretKey}")
    private String secretKey;

    /**
     * 存储桶名称
     */
    @Value("${file.bucket}")
    private String bucket;

    @GetMapping("getToken")
    public String getToken() {
        Auth auth = Auth.create(accessKey, secretKey);
        return auth.uploadToken(bucket);
    }
}
